package com.future.lock.mall.entity.beans;

import com.alibaba.fastjson.annotation.JSONField;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by yzh on 2018/1/6.
 */

public class PayInfo {

    /**
     * alipay_info : {"order_sn":"TEST100202020","total_amount":"100.00","subject":"趣家智能锁商品","timeout_express":"15d"}
     * wx_pay_info : {"appid":"wxca2816298afcf527","mch_id":"1494936702","nonce_str":"B5pkQiEvPTdxMA5l","prepay_id":"wx20171228170310a2ddd3bfd20764464883","result_code":"SUCCESS","return_code":"SUCCESS","return_msg":"OK","sign":"8E5F833F8D41A976508E8C31D2D234BA","trade_type":"APP"}
     * order_id : 1
     * pay_type : 0
     * timestamp : 1514469294
     */

    private AlipayInfoBean alipay_info;
    @JSONField(name = "wx_pay_info")
    private Object wx_pay_info;
    private String order_id;
    private int pay_type;
    private int timestamp;

    public AlipayInfoBean getAlipay_info() { return alipay_info;}

    public void setAlipay_info(AlipayInfoBean alipay_info) { this.alipay_info = alipay_info;}

    public Object getWx_pay_info() { return wx_pay_info;}

    public JSONObject getWxPayJson() {
        JSONObject payInfo = null;
        try {
            payInfo = new JSONObject(wx_pay_info.toString());
            payInfo.put("partnerid", payInfo.optString("mch_id"));
            payInfo.put("prepayid", payInfo.optString("prepay_id"));
            payInfo.put("noncestr", payInfo.optString("nonce_str"));
            payInfo.put("timestamp", timestamp);
            payInfo.put("package", "Sign=WXPay");
        }
        catch (JSONException e) {
            e.printStackTrace();
        }
        return payInfo;
    }

    @JSONField(name = "wx_pay_info")
    public void setWx_pay_info(Object wx_pay_info) { this.wx_pay_info = wx_pay_info;}

    public String getOrder_id() { return order_id;}

    public void setOrder_id(String order_id) { this.order_id = order_id;}

    public int getPay_type() { return pay_type;}

    public void setPay_type(int pay_type) { this.pay_type = pay_type;}

    public int getTimestamp() { return timestamp;}

    public void setTimestamp(int timestamp) { this.timestamp = timestamp;}

    public static class AlipayInfoBean {
        /**
         * order_sn : TEST100202020
         * total_amount : 100.00
         * subject : 趣家智能锁商品
         * timeout_express : 15d
         */

        private String order_sn;
        private Double total_amount;
        private String subject;
        private String timeout_express;

        public String getOrder_sn() { return order_sn;}

        public void setOrder_sn(String order_sn) { this.order_sn = order_sn;}

        public Double getTotal_amount() { return total_amount;}

        public void setTotal_amount(Double total_amount) { this.total_amount = total_amount;}

        public String getSubject() { return subject;}

        public void setSubject(String subject) { this.subject = subject;}

        public String getTimeout_express() { return timeout_express;}

        public void setTimeout_express(String timeout_express) { this.timeout_express = timeout_express;}
    }
}
